package cn.qiao.demo.controller;

import cn.qiao.demo.annotation.UniversalLog;
import cn.qiao.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RequestCallback;
import sun.nio.cs.ext.GBK;

import javax.servlet.ServletInputStream;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * Created on 2022/2/11
 * @author qiao
 * @Desc:
 */
@RestController
@RequestMapping("/Test")
public class TestController {

    public static int a = 0;


//    @Autowired
//    private TestService testService;
//
//    @PostMapping("/test1")
//    @UniversalLog(operationName = "select")
//    public String test(HttpServletRequest request){
//        try {
//            ServletInputStream inputStream = request.getInputStream();
//            ByteArrayOutputStream output = new ByteArrayOutputStream();
//            byte[] buffer = new byte[4096];
//            int n = 0;
//            while (-1 != (n = inputStream.read(buffer))) {
//                output.write(buffer, 0, n);
//            }
//            byte[] bytes = output.toByteArray();
//            String gbk = new String(bytes, "GBK");
//            System.out.println(gbk);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        String s = a++ +"";
//        return s;
//    }

    @GetMapping("/test")
    private Object test (){
        return "test";
    }

}
